package com.combetter.changxing.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 传递数据bean
 * <p>
 * 作者: Chen
 * 日期: $USER_NAME  2018/9/11 15:27
 */
public class EventMessage<T> implements Parcelable{
    private String type;
    private T data;

    public EventMessage(String type, T data) {
        this.type = type;
        this.data = data;
    }

    protected EventMessage(Parcel in) {
        type = in.readString();
    }

    public static final Creator<EventMessage> CREATOR = new Creator<EventMessage>() {
        @Override
        public EventMessage createFromParcel(Parcel in) {
            return new EventMessage(in);
        }

        @Override
        public EventMessage[] newArray(int size) {
            return new EventMessage[size];
        }
    };

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(type);
    }
}
